<!--
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->

<link rel="import" href="../utils/boot.html">
<link rel="import" href="../utils/resolve-url.html">

<script>
/** @suppress {deprecated} */
(function() {
  'use strict';

  /**
   * Sets the global, legacy settings.
   *
   * @deprecated
   * @namespace
   * @memberof Polymer
   */
  Polymer.Settings = Polymer.Settings || {};

  Polymer.Settings.useShadow = !(window.ShadyDOM);
  Polymer.Settings.useNativeCSSProperties =
    Boolean(!window.ShadyCSS || window.ShadyCSS.nativeCss);
  Polymer.Settings.useNativeCustomElements =
    !(window.customElements.polyfillWrapFlushCallback);


  /**
   * Globally settable property that is automatically assigned to
   * `Polymer.ElementMixin` instances, useful for binding in templates to
   * make URL's relative to an application's root.  Defaults to the main
   * document URL, but can be overridden by users.  It may be useful to set
   * `Polymer.rootPath` to provide a stable application mount path when
   * using client side routing.
   *
   * @memberof Polymer
   */
  Polymer.rootPath = Polymer.rootPath ||
    Polymer.ResolveUrl.pathFromUrl(document.baseURI || window.location.href);

  /**
   * Sets the global rootPath property used by `Polymer.ElementMixin` and
   * available via `Polymer.rootPath`.
   *
   * @memberof Polymer
   * @param {string} path The new root path
   * @return {void}
   */
  Polymer.setRootPath = function(path) {
    Polymer.rootPath = path;
  };

  /**
   * A global callback used to sanitize any value before inserting it into the DOM. The callback signature is:
   *
   *     Polymer = {
   *       sanitizeDOMValue: function(value, name, type, node) { ... }
   *     }
   *
   * Where:
   *
   * `value` is the value to sanitize.
   * `name` is the name of an attribute or property (for example, href).
   * `type` indicates where the value is being inserted: one of property, attribute, or text.
   * `node` is the node where the value is being inserted.
   *
   * @type {(function(*,string,string,Node):*)|undefined}
   * @memberof Polymer
   */
  Polymer.sanitizeDOMValue = Polymer.sanitizeDOMValue || null;

  /**
   * Sets the global sanitizeDOMValue available via `Polymer.sanitizeDOMValue`.
   *
   * @memberof Polymer
   * @param {(function(*,string,string,Node):*)|undefined} newSanitizeDOMValue the global sanitizeDOMValue callback
   * @return {void}
   */
  Polymer.setSanitizeDOMValue = function(newSanitizeDOMValue) {
    Polymer.sanitizeDOMValue = newSanitizeDOMValue;
  };

  /**
   * Globally settable property to make Polymer Gestures use passive TouchEvent listeners when recognizing gestures.
   * When set to `true`, gestures made from touch will not be able to prevent scrolling, allowing for smoother
   * scrolling performance.
   * Defaults to `false` for backwards compatibility.
   *
   * @memberof Polymer
   */
  Polymer.passiveTouchGestures = Polymer.passiveTouchGestures || false;

  /**
   * Sets `passiveTouchGestures` globally for all elements using Polymer Gestures.
   *
   * @memberof Polymer
   * @param {boolean} usePassive enable or disable passive touch gestures globally
   * @return {void}
   */
  Polymer.setPassiveTouchGestures = function(usePassive) {
    Polymer.passiveTouchGestures = usePassive;
  };

  Polymer.legacyOptimizations = Polymer.legacyOptimizations ||
      window.PolymerSettings && window.PolymerSettings.legacyOptimizations || false;

  /**
   * Sets `legacyOptimizations` globally for all elements. Enables
   * optimizations when only legacy Polymer() style elements are used.
   *
   * @memberof Polymer
   * @param {boolean} useLegacyOptimizations enable or disable legacy optimizations globally.
   * @return {void}
   */
  Polymer.setLegacyOptimizations = function(useLegacyOptimizations) {
    Polymer.legacyOptimizations = useLegacyOptimizations;
  };

  Polymer.cancelSyntheticClickEvents = typeof Polymer.cancelSyntheticClickEvents === 'boolean'
    ? Polymer.cancelSyntheticClickEvents : true;

  /**
  * Sets `setCancelSyntheticEvents` globally for all elements to cancel synthetic click events
  * fired by older mobile browsers. Modern browsers no longer fire synthetic click events, and
  * the cancellation behavior can interfere when programmatically clicking on elements.
  *
  * @param {boolean} useCancelSyntheticClickEvents enable or disable cancelling synthetic
  * events
  * @return {void}
  */
  Polymer.setCancelSyntheticClickEvents = function(useCancelSyntheticClickEvents) {
    Polymer.cancelSyntheticClickEvents = useCancelSyntheticClickEvents;
  };
})();
</script>
